<?php echo form_open_multipart(uri_string())?>
    <table class="form">
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_customer');?></td>
            <td>
                <select id="position" name="adv_customer_id" class="w300">
                     <?php 
                     foreach($adv_customer as $customer){
                         echo '<option value="'.$customer->adv_customer_id.'">'.$customer->adv_customer_name.'</option>';
                     }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_page');?></td>
            <td>
                <select name ="adv_page_id" id="adv_page_id">
                        <option value="">Trang quảng cáo</option>
                        <?php 
                            foreach($list_page as $page){
                                echo '<option '.(($item->adv_page_id==$page->adv_page_id)?'selected="true"':'').' value="'.$page->adv_page_id.'">'.$page->adv_page_name.'</option>';
                            }
                        ?>
                </select>
            </td>
        </tr>
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_position');?></td>
            <td id="adv_position_opt">
                <select id="adv_position_id" name="adv_position_id" class="w300">
                     <option value="">Vị trí</option>
                     <?php
                        foreach($list_position as $position){
                            echo '<option '.(($position->adv_position_id==$item->adv_position_id)?'selected="true"':'').' value="'.$position->adv_position_id.'">'.$position->adv_position_name.'</option>';
                        }
                     ?>
                </select>
            </td>
        </tr> 
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_name');?></td>
            <td><input type="text" name="adv_title" id="adv_title" class="w250" value="<?php echo $item->adv_title;?>"></td>
        </tr> 
        <tr>
        <td class="label" style="width: 150px;"><?php echo lang('adv_name_en');?></td>
        <td><input type="text" name="adv_title_en" id="adv_title_en" class="w250" value="<?php echo $item->adv_title_en;?>"></td>
        </tr>
        <tr>
            <td class="required label" style="width: 150px;"><?php echo lang('adv_banner_file_type');?></td>
            <td>
                <select id="position" name="adv_file_type" class="w100">
                    <option <?php echo ($item->adv_file_type=='IMG')?'selected="true"':'';?> value="IMG">Hình ảnh</option>
                    <option <?php echo ($item->adv_file_type=='FLA')?'selected="true"':'';?> value="FLA">Flash</option>
                </select>
            </td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_url');?></td>
            <td><input type="text" name="adv_url" id="adv_url"class="w350" value="<?php echo $item->adv_url;?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_link');?></td>
            <td><input type="text" name="adv_link" class="w350" value="<?php echo $item->adv_link;?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_file');?></td>
            <td>
                <?php if($item->adv_file){?>
                    <img alt="<?php echo $item->adv_title;?>" src="<?php echo base_url_site()."uploads/images/adv/vn/".$item->adv_file;?>" width="100" height="100">
                    <?php }else{ ?>
					<img alt="<?php echo $item->adv_title;?>" src="<?php echo base_url_site()."uploads/media/images/noimages.jpg"?>" width="100" height="100" />	
						<?php } ?>
       
                <br/><input type="file" name="adv_file" />
            </td>
        </tr>
         <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_link_en');?></td>
            <td><input type="text" name="adv_link_en" class="w350" value="<?php echo $item->adv_link_en;?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_file_en');?></td>
            <td>
                <?php if($item->adv_file_en){?>
                    <img alt="<?php echo $item->adv_title_en;?>" src="<?php echo base_url_site()."uploads/images/adv/en/".$item->adv_file_en;?>" width="100" height="100">
                    <?php }else{ ?>
					<img alt="<?php echo $item->adv_title_en;?>" src="<?php echo base_url_site()."uploads/media/images/noimages.jpg"?>" width="100" height="100" />	
						<?php } ?>
              <br/> <input type="file" name="adv_file_en" />
            </td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_order');?></td>
            <td><input type="text" name="nb_order" id="nb_order"class="w100" value="<?php echo $item->nb_order;?>"></td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_dt_start');?></td>
            <td>
                <input type="text" name="dt_start" id="dt_start" class="w100" value="<?php echo format_date_show($item->dt_start);?>">
                <script type="text/javascript">
                    var cal = Calendar.setup({
                      onSelect: function(cal) { cal.hide();}
                      });
                      cal.manageFields("dt_start", "dt_start","%d/%m/%Y");
                 </script>
            </td>
        </tr>
        <tr>
            <td class="label" style="width: 150px;"><?php echo lang('adv_dt_end');?></td>
            <td>
                <input type="text" name="dt_end" id="dt_end" class="w100" value="<?php echo format_date_show($item->dt_end);?>">
                <script type="text/javascript">
                    var cal1 = Calendar.setup({
                      onSelect: function(cal) { cal.hide();}
                      });
                      cal1.manageFields("dt_end", "dt_end","%d/%m/%Y");
                 </script>
            </td>
        </tr>
        <tr>
            <td class="label"><?php echo lang('active_deactive');?></td>
            <td>
<!--                <input type="checkbox" name="bl_active" id="bl_active" checked  value="1"  onclick="setCheckboxValue(this);">-->
                <select name="bl_active">
                    <option <?php echo ($item->bl_active==1)?'selected="true"':''?> value="1">Kích hoạt</option>
                    <option <?php echo ($item->bl_active==0)?'selected="true"':''?> value="0">Đợi</option>
                    <option <?php echo ($item->bl_active==-1)?'selected="true"':''?> value="-1">Kết thúc</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" name="bt_submit" value="" class="capnhat">
            </td>
        </tr>  
    </table>
<?php echo form_close()?>
<script type="text/javascript" language="javascript">
    function loadPosition(id_page){
        $.ajax({
            type: "POST",
            url: BASE_URI+"adv/get_position/",
            data: {
                'adv_page_id':id_page
            },
            dataType: 'html',
            async:true,
            error: function (request, status, error){

            },
            success: function(data) {
                $('#adv_position_opt').html(data);
            }
        });
    }
    $(document).ready(function(){
		$("#adv_page_id").change(function(){
            loadPosition($(this).val());
		});
	});
</script>